package com.baosight.sczx.zp.domain;

import java.util.HashMap;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.ep.DaoEPBase;
import com.baosight.iplat4j.util.StringUtils;

public class ZPResourceset extends DaoEPBase {

	private final static String KEY_LABEL = "Name";

	private final static String KEY_NAME = "DisplayName";

	private final static String KEY_DESC = "Desc";

	private String label = " ";

	private String name = " ";

	private String desc = " ";

	public ZPResourceset() {
		initMetaData();
	}

	public ZPResourceset(String label, String name, String desc) {
		this();
		this.label = label;
		this.name = name;
		this.desc = desc;
	}

	@SuppressWarnings("rawtypes")
	public void fromMap(Map map) {
		label = StringUtils.defaultIfEmpty(StringUtils.toString(map.get(KEY_LABEL)), label);
		name = StringUtils.defaultIfEmpty(StringUtils.toString(map.get(KEY_NAME)), name);
		desc = StringUtils.defaultIfEmpty(StringUtils.toString(map.get(KEY_DESC)), desc);
	}

	/**
	 * set the value to Map
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Map toMap() {
		Map map = new HashMap();
		map.put(KEY_LABEL, StringUtils.toString(label, eiMetadata.getMeta(KEY_LABEL)));
		map.put(KEY_NAME, StringUtils.toString(name, eiMetadata.getMeta(KEY_NAME)));
		map.put(KEY_DESC, StringUtils.toString(desc, eiMetadata.getMeta(KEY_DESC)));
		return map;

	}

	public void initMetaData() {
		EiColumn eiColumn;

		eiColumn = new EiColumn(KEY_LABEL);
		eiColumn.setFieldLength(14);
		eiColumn.setDescName("资源组标识");
		eiColumn.setPrimaryKey(true);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn(KEY_NAME);
		eiColumn.setFieldLength(100);
		eiColumn.setDescName("资源组名称");
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn(KEY_DESC);
		eiColumn.setFieldLength(250);
		eiColumn.setDescName("描述");
		eiMetadata.addMeta(eiColumn);

	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
